//
//  MyOrderTableViewSection.m
//  X-Touch2
//
//  Created by shengchao yang on 12-3-28.
//  Copyright (c) 2012年 foxhis. All rights reserved.
//

#import "MyOrderTableViewSection.h"
#import "PluMenu.h"
#import "PluSort.h"
#import "Singleton.h"
#import "Common.h"

@implementation MyOrderTableViewSection

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void) setData:(id)data{
    UILabel *lblPmDescript = (UILabel *)[self.view viewWithTag:TagOfUILabel];
    UILabel *lblSortedCount = (UILabel *)[self.view viewWithTag:TagOfUILabel+1];
    
    if (AppSession.isSortedByMenu) {
        PluMenu *tempMenu = (PluMenu *)data;
        float pluMenuCount = [DataBaseAccess getPluMenuCount:tempMenu.pmCode];
        lblPmDescript.text = JsonField(tempMenu.pmDescripts);
        lblSortedCount.text = [NSString stringWithFormat:@"%@:%0.2f", TranslateStr(@"份数"),pluMenuCount];
    }else {
        PluSort *tempSort = (PluSort *)data;
        float pluSortCount = [DataBaseAccess getPluSortCount:tempSort.psCode];
        lblPmDescript.text = JsonField(tempSort.psDescripts);
        lblSortedCount.text = [NSString stringWithFormat:@"%@:%0.2f", TranslateStr(@"份数"),pluSortCount]; 
    }
}

#pragma mark - View lifecycle
- (void)viewDidLoad{
    [super viewDidLoad];
}
- (void)viewDidUnload{
    [super viewDidUnload];
}
- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
-(void)dealloc{
    MyNSLog(@"MyOrderTableViewSection dealloc index=%d",self.view.tag - TagOfUITableViewSection);
    [super dealloc];
}
@end
